/**
 * 2015，thor.com，all rights reserved。
 * 
 * Project：		thor-common
 * Filename：	QueryResultConverter.java
 * Created：		2015年3月14日
 * Creator：		thor
 */
package com.thor.palmmall.spi.common;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.BeanOperateInfo;
import com.thor.commons.util.StringUtil;

/**
 * @author thor
 *
 */
public class SOperateInfoConverter implements Converter<BeanOperateInfo, SOperateInfo> {

  public static SOperateInfoConverter getInstance() {
    if (instance == null)
      instance = new SOperateInfoConverter();
    return instance;
  }

  private static SOperateInfoConverter instance;

  private SOperateInfoConverter() {
  }

  @Override
  public SOperateInfo convert(BeanOperateInfo source) {
    if (source == null)
      return null;

    SOperateInfo target = new SOperateInfo();
    target.setOperator(SOperatorConverter.getInstance().convert(source.getOperator()));
    target.setTime(StringUtil.dateToString(source.getTime(), "yyyy.MM.dd HH:mm:ss"));

    return target;
  }
}
